package fr.contacts.models;

import java.io.Serializable;
import java.text.SimpleDateFormat;
import java.util.ArrayList;
import java.util.Date;
import java.util.List;


public class Contact implements Comparable<Contact>, Serializable {
	
	/**
	 * 
	 */
	private static final long serialVersionUID = 7378722928945235743L;

	private int id;

	private String nom;
	
	private String prenom;
	
	private String email;
	
	private Date dateDeNaissance;
	
	private boolean actif;
	
	private List<Adresse> adresseList;
	
	public Contact() {
		adresseList = new ArrayList<Adresse>();
	}

	public String getNom() {
		return nom;
	}

	public void setNom(String nom) {
		this.nom = nom;
	}

	public String getPrenom() {
		return prenom;
	}

	public void setPrenom(String prenom) {
		this.prenom = prenom;
	}

	public String getEmail() {
		return email;
	}

	public void setEmail(String email) {
		this.email = email;
	}

	public String getDateDeNaissance() {
		return new SimpleDateFormat("dd/MM/yyyy").format(dateDeNaissance);
	}
	
	public Date getDate() {
		return dateDeNaissance;
	}

	public void setDateDeNaissance(Date dateDeNaissance) {
		this.dateDeNaissance = dateDeNaissance;
	}

	public Boolean getActif() {
		return actif;
	}

	public void setActif(Boolean actif) {
		this.actif = actif;
	}

	public List<Adresse> getAdresseList() {
		return adresseList;
	}

	public void setAdresseList(List<Adresse> adresseList) {
		this.adresseList = adresseList;
	}

	public int getId() {
		return id;
	}

	public void setId(int id) {
		this.id = id;
	}

	@Override
	public int compareTo(Contact contactParam) {
		String nomParam = contactParam.getNom();
		if (nom.compareTo(nomParam) != 0) {
			return nom.compareTo(nomParam);
		}
		else {
			return prenom.compareTo(contactParam.getPrenom());
		}
	}

	@Override
	public String toString() {
		return "Contact [id=" + id + ", nom=" + nom + ", prenom=" + prenom
				+ ", email=" + email + ", dateDeNaissance=" + dateDeNaissance
				+ ", actif=" + actif + ", adresseList=" + adresseList + "]";
	}
	
	

}
